﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PIMS.Uil
{
    internal class MessageQueue<T>
    {

        private Queue queue=new Queue();

        /// <summary>
        /// 入队
        /// </summary>
        /// <param name="obj"></param>
        public void Enqueue(T obj) 
        {
            lock (queue) 
            {
                queue.Enqueue(obj);
            }        
        }

        /// <summary>
        /// 出队
        /// </summary>
        /// <returns></returns>
        public T Dequeue()
        {
            lock (queue)
            {
                T dic = default(T);
                if (this.queue.Count > 0)
                    dic = (T)queue.Dequeue();
                return dic;
            }           
        }
    }
}
